package com.blue.common.utils;


import com.blue.common.entity.LoginUserInfo;

public class ThreadLocalUtils {

    private final static ThreadLocal<LoginUserInfo> USER_THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 设置当前线程中登录用户信息
     *
     * @param loginUserInfo
     */
    public static void setLoginUserInfo(LoginUserInfo loginUserInfo) {
        USER_THREAD_LOCAL.set(loginUserInfo);
    }

    /**
     * 获取当前线程中登录用户信息
     *
     * @return
     */
    public static LoginUserInfo getLoginUserInfo() {
        return USER_THREAD_LOCAL.get();
    }

    /**
     * 清空线程变量
     */
    public static void clear() {
        USER_THREAD_LOCAL.remove();
    }
}
